home *** CD-ROM | disk | FTP | other *** search
/ Aminet 8 / Aminet 8 (1995)(GTI - Schatztruhe)[!][Oct 1995].iso / Aminet / comm / news / nta_11ld.lha / Next_to_Active / next2active.rexx < prev    next >
OS/2 REXX Batch file  |  1995-07-15  |  2KB  |  81 lines

  1. /*
  2.  Updates UULIB:Active's top article number based on the ".next" files.
  3.  
  4.  Quickly slapped together by Leo Davidson <leo@hampschl.demon.co.uk>
  5.  ("Nudel" in #Amiga on IRC)
  6.  You may do whatever you like with this script, so long as it does not harm
  7.  anyone, :-).
  8. */
  9.  
  10. ActivePath = "UULIB:Active"
  11.  
  12. Say
  13. Say " p Next-to-Active 1.1 by Leo Davidson (IRC: Nudel, Pot-Noodle/Gods'Gift)"
  14. Say " EMail: leo@hampschl.demon.co.uk if you have any problems or comments."
  15.  
  16. Address Command "Copy "||ActivePath||" "||ActivePath||".bak"
  17.  
  18. IF ~OPEN(ActiveFile,ActivePath,"R") THEN DO
  19.     Say "Next2Active: -ABORTED- Couldn't open active file."
  20.     EXIT
  21.     END
  22.  
  23. Say ".---------------------------------------------------------------------."
  24. Say "|                               Group Name |    Low |   High |  Total |"
  25. Say "|---------------------------------------------------------------------|"
  26.  
  27. grand_total = 0
  28.  
  29. x = 0
  30. Do While ~EOF(ActiveFile)
  31.     x = x + 1
  32.     TempErp = ReadLn(ActiveFile)
  33.     If TempErp ~= "" Then Do
  34.         group.x = Word(TempErp,1)
  35.         group_next.x = "UUNews:"||Translate(Word(TempErp,1),"/",".")||"/.next"
  36.     /*    high.x = Word(TempErp,2)    */
  37.         low.x = Word(TempErp,3)
  38.         type_thingy.x = Word(TempErp,4)
  39.  
  40.         IF ~Open(next_file,group_next.x,"R") THEN
  41.             high.x = "0"
  42.         ELSE Do
  43.             high.x = Word(ReadLn(next_file),1)
  44.             Close(next_file)
  45.             END
  46.         IF ~Datatype(high.x,"N") THEN DO
  47.             Say " pNext2Active: -ABORTED- Invalid file: '"||group_next.x||"' (Contents: '"||high.x||"'."
  48.             EXIT
  49.             END
  50.  
  51.         total.x = high.x - low.x
  52.         grand_total = grand_total + total.x
  53.  
  54.         Say "| "||Right(Group.x,40,".")||" | "||Right(low.x,6,".")||" | "||Right(high.x,6,".")||" | "||Right(total.x,6,".")||" |"
  55.  
  56.         END
  57.     END
  58.  
  59. CLOSE(ActiveFile)
  60.  
  61. Say "|---------------------------------------------------------------------|"
  62. Say "Writting new 'Active' file... 0% [------------------] 100% | "||Right(grand_total,6,".")||" |"
  63. Say "`---------------------------------------------------------------------'A"
  64.  
  65. IF ~OPEN(ActiveFile,ActivePath,"W") THEN DO
  66.     Say " pNext2Active: -ABORTED- Couldn't write new active file."
  67.     EXIT
  68.     END
  69.  
  70.  
  71. Do y=1 to x-1
  72.     Say "C"||Copies("=",Trunc(18*(y/(x-1)),0))||"A"
  73.     WriteLn(ActiveFile,group.y high.y low.y type_thingy.y)
  74.     END
  75.  
  76. CLOSE(ActiveFile)
  77.  
  78. Say
  79. Say
  80. Say
  81.